package xgame;

/**
 * 命令处理器结对
 * 
 * @author AfritXia
 * @version $Rev: 15 $
 *
 */
public final class XcommandXhandlerPair {
	/**
	 * 命令对象
	 * 
	 */
	private AbstractXcommand _cmd = null;

	/**
	 * 处理器对象
	 * 
	 */
	private AbstractXhandler<? extends AbstractXcommand> _handler = null;

	/**
	 * 类参数构造器
	 * 
	 * @param cmd
	 * @param handler
	 * @throws IllegalArgumentException if cmd == null or handler == null 
	 * 
	 */
	public XcommandXhandlerPair(AbstractXcommand cmd, 
		AbstractXhandler<? extends AbstractXcommand> handler) {
		if (cmd == null) {
			throw new IllegalArgumentException("cmd is null");
		}

		if (handler == null) {
			throw new IllegalArgumentException("handler is null");
		}

		this._cmd = cmd;
		this._handler = handler;
	}

	/**
	 * 获取命令
	 * 
	 * @return 
	 * 
	 */
	public AbstractXcommand getCommand() {
		return this._cmd;
	}

	/**
	 * 获取处理器
	 * 
	 * @return 
	 * 
	 */
	public AbstractXhandler<? extends AbstractXcommand> getHandler() {
		return this._handler;
	}

	/**
	 * 创建新实例
	 * 
	 * @param cmd
	 * @param handler
	 * @return 
	 * 
	 */
	public static XcommandXhandlerPair newInstance(
		AbstractXcommand cmd, 
		AbstractXhandler<? extends AbstractXcommand> handler) {
		return new XcommandXhandlerPair(cmd, handler);
	}
}
